package com.module.overview.ui.historicalDataDetails

import android.view.View
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.viewpager.widget.ViewPager
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.common.app.base.AppActivity
import com.common.app.core.RouterHub
import com.common.app.data.bean.KeyBundle
import com.common.app.utls.HeadTitleUtils
import com.common.base.adapter.BaseFragmentPageAdapter
import com.common.base.utils.StatusBarUtils
import com.module.overview.R
import com.module.overview.databinding.OverviewActivityHistoricalDataDetailsBinding
import com.module.overview.databinding.OverviewActivitySummaryReportMainBinding

/**
 * 作者：sosou
 * <p>
 * 版本：1.0
 * <p>
 * 创建日期：2025/07/22
 * <p>
 * 描述：总结报告页面
 * <p>
 * 修订历史：
 */
@Route(path = RouterHub.ROUTER_OVERVIEW_HIS_DATA_DETAILS)
class HistoricalDataDetailsActivity :
    AppActivity<OverviewActivityHistoricalDataDetailsBinding, HistoricalDataDetailsViewModel>(),
    View.OnClickListener {

    val TAG: String = HistoricalDataDetailsActivity::class.java.simpleName

    override fun getViewModel() = HistoricalDataDetailsViewModel::class.java

    override fun getViewContentBinding() = OverviewActivityHistoricalDataDetailsBinding.inflate(layoutInflater)

    override fun isShowToolBar(): Boolean = false
    override fun isStatusBarTranslate(): Boolean = true

    @Autowired(name = KeyBundle.BUNDLE_TITLE)
    @JvmField
    var mTitle: String? = null

    override fun initViews() {
        super.initViews()
        StatusBarUtils.setStatusBarHeight(mViewContentBinding.statusView)
        StatusBarUtils.setStatusBarForegroundColor(this, true)


        val headTitleUtils = HeadTitleUtils(this)
        headTitleUtils.setTitle(mTitle?:"")
        headTitleUtils.setLineStyle(10)


        val titles = ArrayList<String>()
        titles.add(resources.getString(R.string.common_week_unit))
        titles.add(resources.getString(R.string.common_month_unit))
        titles.add(resources.getString(R.string.common_year_unit))
        val mFragments = arrayListOf<Fragment>()
        mFragments.add(HistoricalDataDetailsFragment.newInstance(1,mTitle?:""))
        mFragments.add(HistoricalDataDetailsFragment.newInstance(2,mTitle?:""))
        mFragments.add(HistoricalDataDetailsFragment.newInstance(3,mTitle?:""))

        val mAdapter = BaseFragmentPageAdapter(supportFragmentManager, mFragments, titles)
        mViewContentBinding.viewPager.adapter = mAdapter
        mViewContentBinding.viewPager.offscreenPageLimit = mFragments.size


        mViewContentBinding.viewPager.currentItem = 0
    }

    override fun initEvents() {
        super.initEvents()

        mViewContentBinding.rgReport.setOnCheckedChangeListener { radioGroup, i ->
            // 选中状态改变时被触发
            when (i) {
                R.id.rbnWeeks -> mViewContentBinding.viewPager.setCurrentItem(0,true)
                R.id.rbnMonth -> mViewContentBinding.viewPager.setCurrentItem(1,true)
                R.id.rbnYears -> mViewContentBinding.viewPager.setCurrentItem(2,true)
            }
        }

//        mViewContentBinding.v.setOnClickListener(onClick = this)
    }

    override fun lazyInitData() {
        super.lazyInitData()

    }

    override fun onDestroy() {
        super.onDestroy()
    }

    override fun onClick(v: View?) {
        when (v) {
        }
    }
}